
#include <unittest++/UnitTest++.h>
#include <Ape/String.h>

namespace ApeTest {
	using Ape::String;
	
	TEST(Ape_String__Test_eq_operator) {
		String s1 = L"12333361";
		String s2 = "12333361";
		String s3 = L"122";
		
		CHECK_EQUAL(s1 == s2, true);
		CHECK_EQUAL(s1 == s3, false);
	}
	
	TEST(Ape_String__Test_neq_operator) {
		String s1 = L"12333361";
		String s2 = "12333361";
		String s3 = L"122";
		
		CHECK_EQUAL(s1 != s2, false);
		CHECK_EQUAL(s1 != s3, true);
	}
	
	TEST(Ape_String__Test_length) {
		String s1 = "1233231";
		String s2 = "";
		
		CHECK_EQUAL(s1.get_Length(), 7);
		CHECK_EQUAL(s2.get_Length(), 0);
		CHECK_EQUAL(s2.IsEmpty(), true);
		CHECK_EQUAL(s1.IsEmpty(), false);
	}
	
	TEST(Ape_String__Substr) {
		String s1 = L"0123456";
		String s2 = s1.Substr(2, 0); // "01"
		String s3 = s1.Substr(3, 2); // "234"
		
		CHECK_EQUAL(s2, "01");
		CHECK_EQUAL(s3, "234");
	}
	
	TEST(Ape_String__Substring) {
		String s1 = L"0123456789";
		String s2 = s1.Substring(2, 4); // "234"
		
		CHECK_EQUAL(s2, "23");
	}
	
	TEST(Ape_String__LtAndGt) {
		String s1 = "123";
		String s2 = "234";
		String s3 = "124";
		String s4 = "1234";
		
		CHECK_EQUAL(s1 < s2, true);
		CHECK_EQUAL(s1 < s3, true);
		CHECK_EQUAL(s1 < s4, true);
		
		CHECK_EQUAL(s1 > s2, false);
		CHECK_EQUAL(s1 > s3, false);
		CHECK_EQUAL(s1 > s4, false);
	}
}
